<template>
  <!-- 概述 -->
  <div class="member-home-overview">
    <!-- 用户信息 -->
    <div class="user-meta">
      <div class="avatar">
        <img v-lazy="avatar" alt=""/>
      </div>
      <h4>{{ nickname || account }}</h4>
    </div>

    <div class="item">
      <a href="javascript:;">
        <span class="iconfont icon-hy"></span>
        <p>会员中心</p>
      </a>
      <a href="javascript:;">
        <span class="iconfont icon-aq"></span>
        <p>安全设置</p>
      </a>
      <a href="javascript:;">
        <span class="iconfont icon-dw"></span>
        <p>地址管理</p>
      </a>
    </div>
  </div>
</template>

<script>
import { useStore } from 'vuex'
import { computed } from 'vue'

export default {
  name: 'MemberHomeOverview',
  setup() {
    const store = useStore()

    return {
      avatar: computed(() => store.state.user.profile.avatar),
      nickname: computed(() => store.state.user.profile.nickname),
      account: computed(() => store.state.user.profile.account),
    }
  }
}
</script>

<style lang="less" scoped>
.member-home-overview {
  // 注意这个高度一定要加, 宽度的值等同于背景图片的高度
  height: 132px;
  display: flex;
  background: url("../../assets/images/center-bg.png") no-repeat center/contain;

  .user-meta {
    // .user-meta 和 .item 同时使用 flex: 1 这样它们两个类就占满父容器宽度的各一半宽度
    flex: 1;
    display: flex;
    align-items: center;

    .avatar {
      margin-left: 60px;
      // 注意这里不能使用 padding-left 因为设置自动盒子内减, padding属于width的一部分!!
      //padding-left: 60px;
      width: 85px;
      height: 85px;
      border-radius: 50%;
      overflow: hidden;

      img {
        width: 100%;
        height: 100%;
      }
    }

    h4 {
      padding-left: 26px;
      font-size: 18px;
      font-weight: normal;
      color: #fff;
    }
  }

  .item {
    flex: 1;
    display: flex;
    justify-content: space-around;
    align-items: center;

    a {
      text-align: center;
      color: #fff;

      .iconfont {
        font-size: 32px;
      }

      p {
        margin-top: 5px;
        font-size: 16px;
      }
    }
  }
}
</style>
